<template>
  <div class="my-release">
    <div class="release-top">
     <div class="release-top-desc">
      <p>查看网络爬虫数据</p>
      <p>网络爬虫数据展示所有数据列表，通过算法分析，可根据数据主题、时间、地域信息生成分析报告，直观展示数据信息</p>
     </div>
     <div class="release-top-right">
      <el-button type="primary" @click="createBg">生成分析</el-button>
     </div>
    </div>
    <div class="release-content">
      <el-table :data="release.list" border>
        <el-table-column type="index" align="center" width="80px" label="序号"> </el-table-column>
        <el-table-column prop="Title" align="center" label="名称">
          <template #default="scope">
            <a style="color: #333;" :href="scope.row.Url" target="_blank">{{ scope.row.Title }}</a>
          </template>
        </el-table-column>
        <el-table-column prop="ArticleTime" align="center" label="时间"> </el-table-column>
        <el-table-column prop="SiteName" align="center" label="数据来源"> </el-table-column>
        <el-table-column prop="Title" align="center" label="操作" width="100">
          <template #default="scope">
            <el-button size="mini" type="primary" @click="download(scope.row)">下载</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="release-page">
        <el-pagination
          v-model:current-page="release.page"
          :page-size="release.size"
          :small="true"
          :background="true"
          layout="total, prev, pager, next"
          :total="release.total"
          @size-change="getDataList"
          @current-change="getDataList"
        />
      </div>
    </div>
  </div>
</template>
<script lang="ts">
import { defineComponent, onMounted, ref, reactive } from 'vue';
import { useStore } from 'vuex';
import { useRouter } from 'vue-router';
import { downloadFile } from "@/utils";

export default defineComponent({
  name: 'MyRelease',
  setup() {
    const store = useStore();
    const router = useRouter();
    const webName = ref('');
    const release = reactive({
      list: [],
      page: 1,
      size: 10,
      total: 0,
      site_name: ""
    });
    // 获取我的发布列表
    const getDataList = async () => {
      const data = await store.dispatch('task/queryDataList', {
        page: release.page,
        size: release.size,
        site_name: release.site_name
      });
      release.list = data.data_list;
      release.total = data.total;
    };
    const download = (row: any) => {
      downloadFile(row.Title + '\n\t' + row.Content,  row.Title, 'doc');
      console.log(row);
    };
    const createBg = () => {
      router.push({ name: 'dashboard' });
    };
    onMounted(() => {
      getDataList();
    });
    return {
      getDataList,
      download,
      createBg,
      release,
      webName,
    };
  },
});
</script>
<style lang="scss" scoped>
.my-release {
  .release-top {
    @extend %container;
    display: flex;
    justify-content: space-between;
    &-desc {
      display: flex;
      flex-direction: column;
      p {
        &:nth-child(1) {
          color: #282d30;
          font-size: 18px;
          font-weight: bold;
        }
        &:nth-child(2) {
          font-size: 12px;
          color: #848899;
          margin-top: 10px;
        }
      }
    }
    &-right {
      &::v-deep(.el-button) {
        background-color: #0054fe;
        border-color: #0054fe;
      }
    }
  }
  .release-page {
    text-align: right;
    margin-top: 10px;
  }
  .release-content {
    @extend %container;
    margin-top: 10px;
    .step-list {
      padding: 40px 100px;
      display: flex;
      justify-content: space-between;
      li {
        display: flex;
        cursor: pointer;
        align-items: center;
        &:nth-child(1) {
          width: calc((100% - 160px) / 2 );
        }
        &:nth-child(2) {
          width: calc((100% - 160px) / 2 );
        }
        &:nth-child(3) {
          width: 160px;
        }
      }
      .active {
        .step-list-no {
          background: #0054fe;
          border: #0054fe solid 1px;
          color: #ffffff;
        }
        .step-list-tit {
          color: #282d30;
        }
      }
      &-no {
        width: 30px;
        height: 30px;
        display: block;
        color: #d9d9d9;
        border: #d9d9d9 solid 1px;
        border-radius: 50%;
        line-height: 30px;
        text-align: center;
        font-size: 16px;
      }
      &-tit {
        font-size: 16px;
        color: #d8d8d8;
        line-height: 30px;
        margin-left: 10px;
      }
      i {
        display: block;
        flex: 1;
        align-items: center;
        margin: 0 40px;
        height: 1px;
        background: #d9d9d9;
      }
    }
    .choose {
      display: flex;
      align-content: center;
      justify-content: center;
      margin: 100px 0 100px;
      &-tit {
        color: #787b7d;
        line-height: 40px;
        margin-right: 20px;
      }
      &-select {
        width: 60%;
      }
    }
    .search {
      display: flex;
      justify-content: center;
      &::v-deep(.el-button) {
        background-color: #0054fe;
        border-color: #0054fe;
      }
    }
    .deacinfo {
      background: #f8f9fb;
      padding: 20px;
      margin-top: 100px;
      p {
        font-size: 12px;
        color: #a5a9b5;
        line-height: 20px;
      }
      &-tit {
        font-size: 16px!important;
        color: #5c6063!important;
        margin-bottom: 10px;
      }
    }
  }
  .el-form-item {
    margin-bottom: 10px;
  }
  .submit-btn {
    text-align: right;
  }
  .table-expand {
    .el-form-item {
      margin-bottom: 0;
      .el-rate {
        margin: 10px 0;
      }
    }
  }
}
</style>